<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
  <h1>注册页面</h1>
  <form >
      用户名:<input type="text" name="username" v-model="username"
                 @blur="check()" placeholder="用户名">{{info}}<br>
      密码:<input type="text" name="password" v-model="password" placeholder="密码"><br>
      <input type="button" value="注册" @click="reg()"><br>
  </form>
<!--引入axios和vue-->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.14/vue.js"></script>

<script>
    let v = new Vue({
        el:"form",
        data:{
            info:"",
            username:"",
            password:""
        },
        methods:{
            check(){
               let formData =  new FormData();
               formData.append("username",v.username)
                axios.post("/check",formData).then(function (response) {
                    v.info = response.data;
                })
            },
            reg(){
                let formData =  new FormData();
                formData.append("username",v.username);
                formData.append("password",v.password);
                axios.post("/reg",formData).then(function (response) {
                    alert(response.data);
                })
            }
        }
    })
</script>

</body>
</html>